export default {
  methods: {
    /* 查看附件 */
    openViewFile(url) {
      let path = ''
      const fileType = url.substring(url.lastIndexOf('.')).toLowerCase()
      if (['.pdf'].includes(fileType)) {
        path = 'http://192.168.11.242/pdf/web/viewer.html?file='
      } else if (['.docx', '.word', '.ppt', '.pptx', '.excel', '.xlsx', '.xls'].includes(fileType)) {
        path = 'https://view.officeapps.live.com/op/view.aspx?src='
      } else {
        window.open(url, '_blank')
        return
      }
      window.open(path + encodeURIComponent(url), '_blank')
    },
    /* 下载附件 */
    downLoad(url, name) {
      var link = document.createElement('a')
      link.style.display = 'none'
      link.href = url.replace('ossm.ejet.com', 'ejet-manager.oss-cn-hangzhou.aliyuncs.com')
      link.setAttribute('download', name)
      document.body.appendChild(link)
      link.click()
    }
  }
}
